<template>
  <div>
  <div>
    <!--条件筛选-->
    <TopFilter ref="topFilter" :list="topFilterList" :cols="3" labelWidth="110" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :isSelectColumn="true"
      :onColumnsChange="columns => (this.columns = columns)"
      :height="'450'"
       selectionType="single"
      :onRowSelectChange="selectRow"
    >
    </FilterTable>
  </div>
  <div
    :style="{
      position: 'absolute',
      left: 0,
      bottom: 0,
      right: 0,
      zIndex: 9,
      borderTop: '1px solid #e9e9e9',
      padding: '10px 20px',
      background: '#fff',
      textAlign: 'right'
    }"
  >
    <el-button @click="closeDialog(1)">取 消</el-button>
    <el-button type="primary" @click="closeDialog(2)">确 认</el-button>
  </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils/index';
import { getpartinfoPage} from '@/api/graphic/catalogue/index';

export default {
  name: 'partInfoManage',
  mixins: [dictionary],
  data() {
    return {
      topFilterList: this.createTopFilterList(),
      columns: this.createTableColumns(),
      fetchApi: getpartinfoPage,
      fetchParams: { xhrAbort: true },
      visibleDrawer: false,
      visibleImportPeij: false,
      handleType: '',
      formData: {},
      title: '',
      initData: {},
      partinfos: {},
      rowSelectData: [],
      selectRowData: {}
    };
  },
  methods: {
    createTopFilterList() {
      return [
        {
          type: 'INPUT',
          label: '备件代码',
          fieldName: 'bjxmbh'
        },
        {
          type: 'INPUT',
          label: '备件名称',
          fieldName: 'bjzwmc'
        }
      ];
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '备件ID',
          dataIndex: 'id',
          sorter: true,
           hidden:true
        },
        {
          title: '备件代码',
          dataIndex: 'bjxmbh',
          sorter: true
        },
        {
          title: '备件名称',
          dataIndex: 'bjzwmc',
          sorter: true
        }
      ];
    },
    selectRow(row) {
      this.selectRowData = row;
    },
    async closeDialog(param) {
      if (param == 1) {
        this.$emit('close', false, param);
      } else {

        this.$emit('addCustomerCode', this.selectRowData);
        this.closeDialog(1);
      }
    },


    changeHandle(val) {
      this.fetchParams = Object.assign({}, val);
      let params = Object.assign({}, val, { xhrAbort: false });
      this.fetchParams = params;
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
};
</script>

<style scoped></style>
